﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace A2DFramework.FileService.Providers
{
    internal class DFSNetworkShareFileServiceProvider : IFileService
    {
        public void Save(System.Web.HttpPostedFile srcFile, string desFilePath)
        {
            srcFile.SaveAs(desFilePath);
        }

        public void Delete(string filePath)
        {
            File.Delete(filePath);
        }

        public string ReadToEnd(string filePath)
        {
            return File.ReadAllText(filePath);
        }

        public List<string> Dir(string dirPath)
        {
            string[] dirs = Directory.GetDirectories(dirPath);
            string[] files = Directory.GetFiles(dirPath);

            List<string> items = new List<string>();
            if (dirs != null)
                items.AddRange(dirs);
            if (files != null)
                items.AddRange(files);

            return items;
        }
    }
}
